<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style type="text/css">
    #diamond{
        width: 100px;
        height: 100px;
        background-color: red;
        position: absolute;
        left: 0px;
        top: 50px;
    }
</style>
<body>
    <button id="btn">运动吧！小方块</button>
    <div id="diamond"></div>
</body>
<script>
    var btn=document.getElementById('btn');
     var dia=document.getElementById('diamond');
     var count=0;
     btn.onclick=function(){
         time=setInterval(function(){
           count+=10;
         if(count%800==0){
             count=0;
             clearInterval(time);
         }
         dia.style.left=count+'px';  
         },10)
         
     };
</script>
</html>